package tsing.courase.algorithms;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @Date 2024/6/5 14:26
 * @Author Tsing
 */
public class Demo {


    public static void main(String[] args) {

        /*String input = "[\"0-cscs202309050001\"]|[\"0-cscs202309050002\"]|[\"0-0005029LC\",\"1-CXCJ220228ZGYW0062\"]";

        // Step 1: 按照 "],[" 进行分割
        List<String> parts = Arrays.asList(input.split("\\|"));
        System.out.println(JSON.toJSONString(parts));
        System.out.println(parts)       ;

        StringBuilder sb = new StringBuilder();
        String begin = "投资链路变动，详情如下：\n原投资链路：";
        sb.append(begin)
                .append("\n")
                .append("\tA新项目关联a").append("\n")
                .append("变动后").append("\n")
                .append("\tB新项目关联b").append("\n");
        System.out.println(sb.toString());



        Set<String> linkIdSet = Arrays.stream(input.split("\\|")).collect(Collectors.toSet());
        System.out.println((linkIdSet));*/

    }


    /**
     * 斐波那契数列求N向的和
     * @param n
     */
    private static void fibCount(int n) {
        int count = 0;
        for (int i = 1; i <= n ; i++) {
           count += fib(n);
        }
        System.out.println(count);
    }

    /**
     * 实现斐波那契数列 ,求n项
     * @param n
     * @return
     */
    public static int fib(int n ){

        int result = 0;
        if(n==1 || n==2){
            return n-1;
        }
        if(n>2){
            result = fib(n-1)+fib(n-2);
        }

        return result ;

    }



}
